# 开发时间:2025/6/616:18
from  PIL import Image,ImageDraw
import random
import string

def generate_random_str(length=4):
    # 定义字符集（字母+数字）
    charset = string.ascii_letters + string.digits
    # 随机选择并拼接字符
    return ''.join(random.choice(charset) for _ in range(length))
def pic():

    img=Image.new(mode='RGB',size=(120,30),color=(200,200,200))
    draw=ImageDraw.Draw(img,mode='RGB')
    text=generate_random_str()
    draw.text((20,0),text,fill='red',font_size=25)
    return  (img,text)



# with open('app_01/static/img/img1.png','wb') as f:
#     img.save(f,format='png')
